package com.comac.print.component.app.gatewayimpl.print;

import com.comac.print.component.app.domain.gateway.enums.MpStatusEnum;
import com.comac.print.component.app.domain.gateway.enums.SgStatusEnum;
import com.comac.print.component.app.domain.gateway.print.MasterPlateGateway;
import com.comac.print.component.app.domain.gateway.print.SystemGateway;
import com.comac.print.component.app.domain.gateway.printE.MasterPlateE;
import com.comac.print.component.app.domain.gateway.printE.SystemE;
import com.comac.print.component.app.gatewayimpl.database.dataobject.MasterPlateDO;
import com.comac.print.component.app.gatewayimpl.database.dataobject.SystemDO;
import com.comac.print.component.app.gatewayimpl.database.mapper.MasterPlateMapper;
import com.comac.print.component.app.gatewayimpl.database.mapper.SystemMapper;
import com.comac.print.component.app.utils.Md5Utils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static cn.hutool.core.date.DateTime.now;


@Component
public class SystemGatewayImpl implements SystemGateway {

    @Resource
    private SystemMapper systemMapper;

    @Override
    public void create(SystemE systemE) {
        SystemDO systemDO = new SystemDO();
        BeanUtils.copyProperties(systemE,systemDO);
        systemDO.setCreateTime(now());
        systemDO.setStatus(SgStatusEnum.SG_ACTIVE.getCode());
        systemDO.setSystemAk(Md5Utils.getMD5(systemE.getSystemName()));
        systemMapper.insert(systemDO);
    }

}
